//
//  MemberManagementTableViewCell.m
//  NuwaRobot
//
//  Created by Kendama on 2017/12/4.
//  Copyright © 2017年 Kendama. All rights reserved.
//

#import "MemberManagementTableViewCell.h"
#import "NSMutableAttributedString+FIDText.h"
#import "MemberModel.h"
@implementation MemberManagementTableViewCell

- (void)didClickDeleteButton
{
    if (self.deleteBlock)
    {
        self.deleteBlock();
    }
}

- (void)setMemberModel:(MemberModel *)memberModel
{
    NSMutableAttributedString *string = [[NSMutableAttributedString alloc] init];
    self.nameLabel.attributedText = [string attributeStrings:@[memberModel.nickname,[NSString stringWithFormat:@"  (%@)",memberModel.username]] attributes:@[@[[UIColor whiteColor],fontCommonSize],@[[UIColor grayColor],fontWithSize(14)]]];
}

- (void)setName:(NSString *)name phone:(NSString *)phone
{
    NSMutableAttributedString *string = [[NSMutableAttributedString alloc] init];
    self.nameLabel.attributedText = [string attributeStrings:@[name,[NSString stringWithFormat:@"  (%@)",phone]] attributes:@[@[[UIColor whiteColor],fontCommonSize],@[[UIColor grayColor],fontWithSize(14)]]];
}

- (UILabel *)nameLabel
{
    if(!_nameLabel)
    {
        UIView *superView = self.contentView;
        _nameLabel = [[UILabel alloc]init];
        [superView addSubview:_nameLabel];
    }
    return _nameLabel;
}
- (UIButton *)deleteButton
{
    if(!_deleteButton)
    {
        UIView *superView = self.contentView;
        _deleteButton = [[UIButton alloc]init];
        [superView addSubview:_deleteButton];
        [_deleteButton setImage:imageWithName(@"icon_delete1") forState:UIControlStateNormal];
        [_deleteButton addTarget:self action:@selector(didClickDeleteButton) forControlEvents:UIControlEventTouchUpInside];
    }
    return _deleteButton;
}


- (void)masLayoutSubview
{
    __weak UIView *superView = self.contentView;
    superView.backgroundColor = rgba(27,44,81,1);
    
    [self.deleteButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(superView.mas_centerY);
        make.right.mas_equalTo(superView.mas_right).with.offset(-px1080Width(50));
        make.height.width.mas_equalTo(px1920Height(150));
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(superView.mas_centerY);
        make.left.mas_equalTo(superView.mas_left).with.offset(px1080Width(50));
    }];
    
    UIView *lineView = ({
        lineView = [[UIView alloc]init];
        [superView addSubview:lineView];
        lineView.backgroundColor = rgba(6,27,56,1);
        [lineView mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(superView.mas_bottom);
            make.left.right.mas_equalTo(superView);
            make.height.mas_equalTo(px1920Height(1));
        }];
        lineView;
    });
}

@end
